﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Thrift.Transport;
using HelloThriftspace;
using System.Threading;
using Thrift.Protocol;

namespace Thrift.Server
{

    class Program
    {
        static void Main(string[] args)
        {

            try
            {
                new Thread(() =>
                {
                    Project.IoC.ServiceLocator.Instance.GetService<Thrift.IL.IThriftHandle>().Handle(); //开起一些插件服务

                    var processor1 = new HelloThrift.Processor(new HelloThriftHandler());
                    var processor2 = new InputOutputSpace.InputOutput.Processor(new InputOutputHandler());
                    TMultiplexedProcessor processor = new TMultiplexedProcessor();
                    processor.RegisterProcessor("HelloThriftHandler", processor1);
                    processor.RegisterProcessor("InputOutputHandler", processor2);
                    var serverTransport = new TServerSocket(9090);
                    var server1 = new TThreadedServer(processor, serverTransport);
                    Console.WriteLine("向客户端输出服务开启");
                    server1.Serve();

                }).Start();

                //new Thread(() =>
                //{
                //    var processor = new InputOutputSpace.InputOutput.Processor(new InputOutputHandler());
                //    var serverTransport = new TServerSocket(9091);
                //    var server = new TSimpleServer(processor, serverTransport);
                //    Console.WriteLine("文字处理服务开启...");
                //    server.Serve();
                //}).Start();

                //服务器开新线程响应
                //new Thread(() =>
                //{
                //    var processor = new FileTransportSpace.FileTransport.Processor(new FileTransportHandler());
                //    var serverTransport = new TServerSocket(9090);
                //    var server = new TSimpleServer(processor, serverTransport);
                //    Console.WriteLine("文件传输服务开启...");
                //    server.Serve();
                //}).Start();






                Console.WriteLine("DO...");
                Console.ReadKey();
            }
            catch (Exception)
            {
                throw;
            }

        }
    }
}
